package JZOffer;

/**
 * @author Lw中
 * @date 2021/9/5 16:58
 */
public class Jz53II {

    // Jz53 II.0～n-1中缺失的数字
    public int missingNumber(int[] nums) {

        // 使用二分查找
        int i = 0, j = nums.length - 1;
        while (i <= j) {
            int m = (i + j) / 2;
            if (nums[m] == m) i = m + 1;
            else j = m - 1;
        }
        return i;

    }

}
